import React from 'react'
import { getAdList } from '../../../../apis/shop'
import AdListUl from './adListUl'
class Ad extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.state = {
            data: []
        }
    }
    render() {
        return (
            this.state.data.length
                ? <AdListUl data={this.state.data} />
                : <div>{/* 加载中... */}</div>
        )
    }
    componentDidMount() {
        // 获取广告数据
        getAdList().then(res => {
            if (res.data.length) {
                this.setState({
                    data: res.data
                })
            }
        }).catch(ex => {
            // 发生错误
            console.error('首页广告模块获取数据报错, ', ex.message);
        })
    }
}
export default Ad